import 'package:flutter/material.dart';
import 'package:myapp/bean/article.dart';
import 'package:myapp/globle/route_manager.dart';
import 'package:myapp/util/colors_utils.dart';
import 'package:myapp/widget/article_tag.dart';

class ItemArticleWidget1 extends StatelessWidget {
  final Article article;

  const ItemArticleWidget1({Key key, this.article}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
          color: ColorUtils.color_bg_1,
          padding: EdgeInsets.all(8),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  if (article.top)
                    Text(
                      "置顶",
                      style: TextStyle(
                        color: Colors.redAccent,
                        fontSize: 13,
                      ),
                    ),
                  Padding(
                    padding: EdgeInsets.only(left: 4, right: 4),
                    child: Text(
                      article.author,
                      style: TextStyle(
                        color: ColorUtils.color_text_1,
                        fontSize: 13,
                      ),
                    ),
                  ),
                  ArticleTag(article.chapterName,
                      color: ColorUtils.color_text_3),
                  Expanded(
                      child: Text(
                        "干货/干货",
                        textAlign: TextAlign.right,
                        style: TextStyle(
                          color: ColorUtils.color_text_3,
                          fontSize: 12,
                        ),
                      ))
                ],
              ),
              Padding(
                padding: EdgeInsets.only(top: 8, bottom: 4),
                child: Text(
                  article.title,
                  style: TextStyle(
                      color: ColorUtils.color_text_1,
                      fontSize: 14),
                ),
              ),
              Padding(
                padding: EdgeInsets.only(bottom: 8),
                child: Text(
                  article.desc,
                  maxLines: 3,
                  overflow: TextOverflow.ellipsis,
                  style:
                  TextStyle(color: ColorUtils.color_text_3),
                ),
              ),
              Row(
                children: [
                  Text(
                    article.niceDate,
                    style: TextStyle(
                        fontSize: 12,
                        color: ColorUtils.color_text_3),
                  ),
                  Spacer(),
                  InkWell(
                    child: Icon(
                      Icons.star_border,
                      size: 18,
                      color: ColorUtils.color_text_3,
                    ),
                    onTap: () {},
                  ),
                ],
              )
            ],
          )),
      onTap: () {
        Navigator.pushNamed(
            context, RouteName.ARTICLE_DETAIL_PAGE,arguments: article);
      },
    );
  }
}
